﻿@using System.Globalization
@model IEnumerable<WebApplication.Models.Work>

@{
    ViewBag.Title = "Works";
    var state = new List<string>
    {
        "new", "run", "completed", "suspended"
    };
}

<h2>Works</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayName("Name")
        </th>
        <th>
            @Html.DisplayName("DataSet")
        </th>
        <th>
            @Html.DisplayName("Time")
        </th>
        <th>
            @Html.DisplayName("State")
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr style="background-color:
        @{
            switch (item.state)
            {
                case 0:
                    Write("white");
                    break;
                case 1:
                    Write("lightgreen");
                    break;
                case 2:
                    Write("lightcoral");
                    break;
                case 3:
                    Write("lightblue");
                    break;
            }

        }">
        <td>
        @Html.DisplayName(item.name)
        </td>
        <td>
        @Html.DisplayName(item.DataSet.name)
        </td>
        <td>
            @Html.DisplayName(item.startTime.ToString(CultureInfo.CurrentCulture))
        </td>
   
        <td>
        @Html.DisplayName(state[item.state])
        </td>
        <td>
        @Html.ActionLink("Edit", "Edit", new {item.id }) |

        @Html.ActionLink("Delete", "Delete", new {item.id })
        </td>
        </tr>
            }

</table>
